
const beamcoder = require('beamcoder');

async function get_base_info(){
    let demuxer = await beamcoder.demuxer('../../media/gh_1.mp4');
    console.log('视频信息如下：');
    let videoPar = demuxer.streams[0].codecpar;
    let audioPar = demuxer.streams[1].codecpar;

    let videoInfo = { ...videoPar }
    let audioInfo = { ...audioPar }
    videoInfo =Object.fromEntries(Object.entries(videoInfo).filter(([key,value])=>value!=='unknown' && value!==0));
    audioInfo =Object.fromEntries(Object.entries(audioInfo).filter(([key,value])=>value!=='unknown' && value!==0));
    console.log('视频信息为', videoInfo);
    console.log('音频信息为', audioInfo);
 /*
完整输入内容如下：
视频信息为 {
  type: 'CodecParameters',
  codec_type: 'video',
  codec_id: 27,
  name: 'h264',
  codec_tag: 'avc1',
  extradata: <Buffer 01 42 c0 1f ff e1 00 17 67 42 c0 1f d9 00 94 19 79 b8 40 00 00 03 00 40 00 00 0c 83 c6 0c 92 01 00 05 68 cb 83 cb 20>,
  format: 'yuv420p',
  bit_rate: 243194,
  bits_per_coded_sample: 24,
  bits_per_raw_sample: 8,
  profile: 'Constrained Baseline',
  level: 31,
  width: 582,
  height: 800,
  sample_aspect_ratio: [ 0, 1 ],
  chroma_location: 'left',
  channel_layout: '0 channels'
}
音频信息为 {
  type: 'CodecParameters',
  codec_type: 'audio',
  codec_id: 86018,
  name: 'aac',
  codec_tag: 'mp4a',
  extradata: <Buffer 11 88 56 e5 00>,
  format: 'fltp',
  bit_rate: 65349,
  bits_per_coded_sample: 16,
  profile: 'LC',
  level: -99,
  sample_aspect_ratio: [ 0, 1 ],
  chroma_location: 'unspecified',
  channel_layout: 'mono',
  channels: 1,
  sample_rate: 48000,
  frame_size: 1024
}*/
}

get_base_info()

